<?php
include ("config.php");
include ("class/tbs_class.php");
include ("class/class_database.php");
include ("class/class_common.php");
include ("class/class_login.php");


//************ FORM ACTION **************
if (GetParam("form","")=="Login") {
	Login();
}


//******* DATABASE FORM QUERY ***********


//******* SHOW FORM CONTENT *********
$FileName   = "login.php";
$FormAction = $FileName . "?" . AddParam(GetQueryString("QueryString", ""),"form","Login");
//$FormEncType = "application/x-www-form-urlencoded";
$HTMLFormName = "LoginForm";

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($ROOT_TEMPLATE_DIR."/login.html");

$TBS->MergeBlock("ktrblk",$DBConnection->GetConnection1(),"SELECT * FROM tblkantor");
$TBS->Show();





//*************** ACTION FUNCTION *******************
function Insert() {

}

function Update() {

}

function Delete() {

}

function Login() {
	 global $DBConnection;
	 $SQL = "SELECT ktrasl FROM tblprofile";
	 $KTRASL = $DBConnection->dbc->get_var($SQL);
	 $Result = LoginUser(GetParam("username",""), GetParam("password",""), $KTRASL);
	 if (!$Result) {
	 	print "<script>alert('Login or password is incorrect!')</script>";
	 } else {
	     header("Location: ".GetParam("ret_link",""));
		 exit;
	 }
}

function Search () {

}


//*************** USER FUNCTION *******************
?>